package kr.co.dongpang.android;

import java.text.DecimalFormat;
import java.util.HashMap;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sys.app.cms.util;

public class postAdapter extends BaseAdapter {
	LayoutInflater inflater;
	HashMap<String, String> hm;
	Context mContext;
	int mListLayout;
	public int[] listRowColora;
	public String TAG = "orderListAdapter";
	public int listCount = 0;
	public util cmsutil = new util();
	public postAdapter(Context tContext, int listLayout,
			HashMap<String, String> hmTmp) {
		mContext = tContext;
		mListLayout = listLayout;
		hm = hmTmp;

		inflater = (LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		if (hm != null) {
			listCount = cmsutil.str2int(hm.get("count"));
		}
		listRowColora = new int[] {
				tContext.getResources().getColor(R.color.abc_search_url_text_holo),
				tContext.getResources().getColor(R.color.abc_search_url_text_normal) };
		
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listCount;
	}

	@Override
	public Object getItem(int rowNum) {
		// TODO Auto-generated method stub
		return hm.get("ordno[" + rowNum + "]");
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public HashMap<String, Bitmap> hmImg = new HashMap<String, Bitmap>();

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null) {
			convertView = inflater.inflate(mListLayout, parent, false);
		}

		((TextView) convertView.findViewById(R.id.zipcode)).setText(hm.get("zipcode[" + position + "]"));
		String address = hm.get("sido[" + position + "]")+ " " +hm.get("gugun[" + position + "]")+ " " +hm.get("dong[" + position + "]");
		((TextView) convertView.findViewById(R.id.address)).setText(address);

		convertView.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				
				
				//detailInfo(position);				
			}
		});
		
		return convertView; 
	}

	public void detailInfo(int position) {
		
//		Intent intent = new Intent(mContext, joinSm.class);
//		intent.putExtra("zipcode", hm.get("zipcode[" + position + "]"));
//		mContext.startActivity(intent);
	}

}
